package demoMod.invincibleOne.powers;

import basemod.ReflectionHacks;
import com.megacrit.cardcrawl.actions.common.LoseHPAction;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.AbstractCreature;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.localization.PowerStrings;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.powers.AbstractPower;
import demoMod.invincibleOne.InvincibleOneMod;

public class HeavyAndHeavyPower extends AbstractPower {
    public static final String POWER_ID = InvincibleOneMod.makeID("HeavyAndHeavyPower");
    private static final PowerStrings powerStrings = CardCrawlGame.languagePack.getPowerStrings(POWER_ID);
    public static final String NAME = powerStrings.NAME;
    public static final String[] DESC = powerStrings.DESCRIPTIONS;

    public HeavyAndHeavyPower(AbstractCreature owner, int amount) {
        this.owner = owner;
        this.ID = POWER_ID;
        this.name = NAME;
        this.amount = amount;
        this.updateDescription();
        loadRegion("painfulStabs");
    }

    @Override
    public void updateDescription() {
        this.description = String.format(DESC[0], this.amount);
    }

    @Override
    public void atStartOfTurn() {
        if (owner instanceof AbstractMonster && ((AbstractMonster) owner).intent.name().contains("ATTACK")) {
            AbstractPlayer p = AbstractDungeon.player;
            int multi = 1;
            if ((int) ReflectionHacks.getPrivate(owner, AbstractMonster.class, "intentMultiAmt") > 0) {
                multi = ReflectionHacks.getPrivate(owner, AbstractMonster.class, "intentMultiAmt");
            }
            if (((AbstractMonster) owner).getIntentDmg() * multi > 25) {
                this.flash();
                addToBot(new LoseHPAction(p, owner, (int) Math.floor(((AbstractMonster) owner).getIntentDmg() * multi * (amount / 100.0F))));
            }
        }
    }
}
